package org.yzl.designPatterns.observer.impl;

import org.yzl.designPatterns.observer.IObserver;
import org.yzl.designPatterns.observer.ISubject;

import java.util.Vector;

public abstract class SubjectImpl implements ISubject {

    private Vector<IObserver> vectors = new Vector();
    @Override
    public void add(IObserver observer) {
        vectors.add(observer);
    }

    @Override
    public void del(IObserver observer) {
        vectors.remove(observer);
    }

    @Override
    public void notifyObservers() {
        for(IObserver vector : vectors){
            vector.update();
        }
    }
    public abstract void operation();
}
